<?php
require_once ('include/permiss.php');
require_once('config.php');
if (isset($_GET['action']) == 'edit') {
    $order_id = $_GET['order_id'];
    $pdo = $conn->prepare('UPDATE datab_order SET order_status=? WHERE order_id=?');
    $pdo->execute(array($_GET['status'], $order_id));
    $kq = 0;
    if ($pdo->rowCount()) {
        $kq = 1;
    }

    header('Location: controlpanel.php?token=' . $_GET['token']);
}

if (isset($_POST['submit'])) {
    $order_id = $_POST['order_id'];
    $pdo = $conn->prepare('UPDATE datab_order SET order_status=?, order_modifi=? WHERE order_id=?');
    $pdo->execute(array($_POST['order_status'], date("Y-m-d H:i:s"), $order_id));
    $kq = 0;
    if ($pdo->rowCount()) {
        $kq = 1;
    }

    header('Location: order.php?token=' . $_GET['token']);
}
?>
<div class="box">
    <div class="box-heading">Cập nhật trạng thái</div>
    <div class="box-content" style='width: 500px; height: 300px;'>
        <form action='optionstatus.php?token=<?php echo $_SESSION['token']; ?>' method='post'>
            Trạng thái:
            <select name='order_status'>
                <option value='0'>Chờ xử lý</option>
                <option value='1'>Đang xử lý</option>
                <option value='2'>Hoàn thành</option>
            </select>
            <input type='hidden' name='order_id' value='<?php echo $_GET['order_id'] ?>'>
            <input type='submit' name='submit' value='Cập nhật'>
        </form>
    </div>
</div>
